package olga.gorbatiuk.record.comparators;

import java.util.Comparator;

import olga.gorbatiuk.record.Record;

public class ByDateAndImportanceComparator implements Comparator<Record> {

    @Override
    public int compare(Record o1, Record o2) {
	int result = o1.getImportance().ordinal()
		- (o2.getImportance().ordinal());// o2.getImportance().getIntValue();
	if (result != 0) {
	    return result;
	} else {
	    result = o1.getTime().compareTo(o2.getTime());
	    if (result != 0) {
		return result;
	    }
	}
	return 0;
    }
}
